<?php
require_once('../db/check_login.php');
require_once('../db/config.php');
$db=new db($config);
$id=$_GET['id'];
$columnsData=$db->foundbyId('columns',$id);

?>
<p>修改栏目</p>
<form name="form1" method="post" action="">
<table width="100%" border="0">
  <tr>
    <td width="13%" align="center">名称</td><td width="87%">
      <label for="name"></label>
      <input type="text" name="name" id="name" value="<?php echo $columnsData['name']?>">
    </td>
    </tr>
    <td width="13%" align="center">权限值</td><td><input type="text" name="power" id="power" value="<?php echo $columnsData['power']?>"></td>
    </tr>
    <td width="13%" align="center">排序</td><td><input type="text" name="sort" id="sort" value="<?php echo $columnsData['sort']?>"></td>
    </tr>
    <td width="13%" align="center">&nbsp;</td>
    <td><input type="submit" name="sub" id="sub" value="提交"></td>
    </tr>
</table>
</form>
<?php 
if(isset($_POST['sub'])){
$data=array(
'name'=>$_POST['name'],
'power'=>$_POST['power']	
);
if(!empty($_POST['sort'])){
$data['sort']=$_POST['sort'];
 }
$row=$db->update('columns',$data,"id=$id");
if($row>0){
echo '<script type="text/javascript">alert("修改成功");location=("list.php");</script>';	
}
}
?>